
mod my;

fn function() {
    println!("called `function()`");
}

mod cool {
    pub fn function() {
        println!("called `cool::function()`");
    }
}

mod mine {
    fn function() {
        println!("called `mine::function()`");
    }

    mod cool {
        pub fn function() {
            println!("called `mine::cool::function()`");
        }
    }

    pub fn indirect_call() {
        print!("called `mine::indirect_call()`, that\n> ");
        self::function();
        function();
        self::cool::function();
        super::function();
        {
            use crate::cool::function as root_function;
            root_function();
        }
    }

    pub struct OpenBox<T> {
        pub contents: T,
    }

    #[allow(dead_code)]
    pub struct ClosedBox<T> {
        contents: T,
    }

    impl<T> ClosedBox<T> {
        pub fn new(contents: T) -> ClosedBox<T> {
            ClosedBox {
                contents: contents,
            }
        }
    }
}


fn main() {

    mine::indirect_call();

    let open_box = mine::OpenBox { contents: "public information" };

    println!("The open box contains: {}", open_box.contents);

    let _closed_box = mine::ClosedBox::new("classified information");


    my::function();

    function();

    my::indirect_access();

    my::nested::function();

    // inaccessible 是私有的mod
    // my::inaccessible::public_function();

    // crates
    // 默认生成二进制文件， --crate-type lib  生成库文件

}